package com.my.study.controller;

import com.my.study.annotation.Encrypt;
import com.my.study.dto.UserInfoDTO;
import com.my.study.entity.vo.ResponseVO;
import com.my.study.service.UserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/login-log")
@Slf4j
public class LoginController {

    @Autowired
    private UserInfoService userInfoService;

    @PostMapping("/login")
    @Encrypt
    public ResponseVO login(@RequestParam(name = "password") String password, @RequestParam(name = "userName") String userName,
                            HttpServletResponse response){
        UserInfoDTO userInfoDTO = new UserInfoDTO();
        userInfoDTO.setPassword(password);
        userInfoDTO.setUserName(userName);
        return ResponseVO.success(userInfoService.queryUserInfo(userInfoDTO,response));
    }
}
